<template>
  <div class="pro-select">
    <span class="name">按省份选择:</span>
    <Select
      :list="list"
      :showListActive="provinceActive"
      @changeListActive="changeProvinceActive"
      @docuemntChangeActive="changeActive"
    />
    <Select
      :list="list1"
      :showListActive="cityActive"
      @changeListActive="changeCityActive"
      @docuemntChangeActive="changeActive"
    />
    <div class="search">
      <span>直接搜索：</span>
      <el-select
        v-model="value"
        filterable
        remote
        reserve-keyword
        placeholder="请输入关键词"
      >
        <el-option v-for="(item, i) in list.col1" :key="i" :value="item.name">
        </el-option>
      </el-select>
    </div>
  </div>
</template>

<script>
import Select from "../../components/select.vue";
export default {
  components: {
    Select,
  },
  data() {
    return {
      provinceActive: false,
      cityActive: false,
      loading: false,
      value: [],
      proviceList: [],
      list: {
        title: "省份",
        col1: [
          { name: "上海", tab: "sh" },
          { name: "哈尔滨", tab: "hrb" },
          { name: "甘肃", tab: "gs" },
          { name: "江苏", tab: "js" },
          { name: "北京", tab: "bj" },
          { name: "云南", tab: "yn" },
          { name: "海南", tab: "hn" },
          { name: "浙江", tab: "zj" },
          { name: "天津", tab: "tj" },
          { name: "陕西", tab: "sx" },
          { name: "新疆", tab: "xj" },
          { name: "贵州", tab: "gz" },
        ],
      },
      list1: {
        title: "城市",
        col1: [
          { name: "上海", tab: "sh" },
          { name: "哈尔滨", tab: "hrb" },
          { name: "甘肃", tab: "gs" },
          { name: "江苏", tab: "js" },
          { name: "北京", tab: "bj" },
          { name: "云南", tab: "yn" },
          { name: "海南", tab: "hn" },
          { name: "浙江", tab: "zj" },
          { name: "天津", tab: "tj" },
          { name: "陕西", tab: "sx" },
          { name: "新疆", tab: "xj" },
          { name: "贵州", tab: "gz" },
        ],
      },
    };
  },
  methods: {
    changeProvinceActive(e) {
      this.provinceActive = !this.provinceActive;
      if (this.provinceActive !== false) {
        this.cityActive = false;
      }
    },
    changeCityActive() {
      this.cityActive = !this.cityActive;
      if (this.cityActive !== false) {
        this.provinceActive = false;
      }
    },
    changeActive(e) {
      this.cityActive = e;
      this.provinceActive = e;
    },
  
  },
};
</script>

<style lang="less" scoped>
.pro-select {
  padding-bottom: 30px;
  border-bottom: 1px solid #e5e5e5;
  .search {
    display: inline-block;
    margin-left: 40px;
    position: relative;
    .search-text {
      width: 220px;
      height: 40px;
      padding: 0 10px;
      border: 1px solid #e5e5e5;
      box-sizing: border-box;
      margin-left: 10px;
      font-size: 14px;
      color: #666;
      border-radius: 4px;
    }
  }
}
</style>